
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
json-schema-diff
Advanced tools
A language agnostic CLI tool and nodejs api to identify differences between two json schema files.
A language agnostic CLI tool and nodejs api to identify differences between two json schema files.
Install the tool using npm and add it to the package.json
npm install json-schema-diff --save-dev
This tool identifies differences between two json schema files. KEYWORDS.md contains the details of what json schema keywords are supported. Differences are classified into two broad groups, added and removed.
Added differences are areas where the destination schema has become more permissive relative to the source schema. For example {"type": "string"}
-> {"type": ["string", "number"]}
.
Removed differences are areas where the destination schema has become more restrictive relative to the source schema. For example {"type": ["string", "number"]}
-> {"type": "string"}
.
Invoke the tool with a file path to the source schema file and the destination schema file. These files should be in JSON format and be valid according to the json schema draft-07 specification.
The tool will return two json schemas as output, one representing the values that were added by the destination schema and the other representing the values that were removed by the destination schema.
The tool will fail if any removed differences are detected.
/path/to/source-schema.json
{
"type": "string"
}
/path/to/destination-schema.json
{
"type": ["string", "number"]
}
Invoking the tool
json-schema-diff /path/to/source-schema.json /path/to/destination-schema.json
Output
Non-breaking changes found between the two schemas.
Values described by the following schema were added:
{
"type": [
"number"
]
}
Values described by the following schema were removed:
false
Invoke the library with the source schema and the destination schema. These objects should be simple javascript objects and be valid according to the json schema draft-07 specification.
For full details of the nodejs api please refer to api-types.d.ts
const jsonSchemaDiff = require('json-schema-diff');
const source = {type: 'string'};
const destination = {type: ['string', 'number']};
const result = await jsonSchemaDiff.diffSchemas({
sourceSchema: source,
destinationSchema: destination
});
if (result.removalsFound) {
console.log('Something was removed!');
}
if (result.additionsFound) {
console.log('Something was added!');
}
See CHANGELOG.md
See CONTRIBUTING.md
See LICENSE.txt
FAQs
A language agnostic CLI tool and nodejs api to identify differences between two json schema files.
The npm package json-schema-diff receives a total of 138,926 weekly downloads. As such, json-schema-diff popularity was classified as popular.
We found that json-schema-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.